package com.selfdriving.wl.activity;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.TextView;

import com.selfdriving.BaseFragmentActivity;
import com.selfdriving.R;
import com.selfdriving.utils.ServiceUtils;

public class AddMyFriends extends BaseFragmentActivity implements
		OnClickListener
{
	EditText editText;
	private TextView title;
	private ImageButton imgBreak;
	private Button addFriends;

	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		super.setContentView(R.layout.w_activity_add_friends);
		initViews();
		initEvents();
	}

	@Override
	protected void initViews()
	{
		// TODO Auto-generated method stub
		title = (TextView) super.findViewById(R.id.top_text_middle);
		imgBreak = (ImageButton) super.findViewById(R.id.head_break);
		addFriends = (Button) findViewById(R.id.top_right_but);
		addFriends.setVisibility(View.VISIBLE);
		addFriends.setText("查找");
		imgBreak.setVisibility(View.VISIBLE);
		title.setText("添加好友");
		editText = (EditText) super.findViewById(R.id.input_phone);

	}

	@Override
	protected void initEvents()
	{
		imgBreak.setOnClickListener(this);
		addFriends.setOnClickListener(this);
	}

	@Override
	public void onClick(View v)
	{
		// TODO Auto-generated method stub
		switch (v.getId())
		{
		case R.id.head_break:
			finish();
			break;
		case R.id.top_right_but:
			String phone = editText.getText().toString().trim();
			if (phone.length() < 1)
			{
				return;
			}
			ServiceUtils.post(this, phone);
			break;
		}
	}

}
